<extend name="Index:base" />
<block name="title"><title>设置</title></block>
<block name="style">
 <style>
.main,.panel-default>.panel-heading{
background:none;
}
body{
background:none;
}
.panel.panel-default,.panel .panel-body,.panel .panel-heading,.table-bordered {
	border:none;
}
.table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
	border:none;		
	padding:15px;	
	line-height:8px;
	height: 8px;
	border-top: 1px solid #d4d4d4;
	border-bottom: 1px solid #d4d4d4;
}
 </style>
</block>
	<!-- start: Header -->
<block name="body">

			<!-- end: Main Menu -->
						
		<!-- start: Content -->
		<div class="main ">
		
			<div class="row">
				<div class="col-lg-12">
					<h3 class="page-header"><i class="fa fa-life-bouy"></i>后台设置</h3>
				</div>
			</div>

			<div class="row">		
				<div class="col-lg-12">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h2><span class="break"></span><strong>导航菜单设置</strong></h2>&nbsp;&nbsp;&nbsp;
							<a class="btn btn-success" role="button" data-toggle="modal" href="#again" id="add_right">添加</i></a>	<a class="btn btn-primary" href="{:U('Admset/adminset')}?clear=1" id="add_right">强制刷新</i></a>			
						</div>&nbsp;&nbsp;&nbsp;
						<ol class="breadcrumb" style="height:55px;background-color: #ffffff;">							
							<li><i class="fa fa-warning"></i><a href="#">操作提示：</a></li><br/>	
							<li><font style="font-size:8px;color:#888;">不需要的功能管理员可直接关闭，导航名称可修改，地址URL和所属上级导航不可修改！</font></li>							
						</ol>
						<div class="panel-body">
							<div class="col-md-12" style="background-color:#f5f5f5;padding:0;">
							</div>
							<table class="table table-striped table-bordered bootstrap-datatable datatable">
							  <thead>
								  <tr>
									  <th>ID</th>
                                      <th>名称</th>
                                      <th>URL</th>
									  <th>状态</th>
									  <th>开启/关闭</th>
									  <th>操作</th>
								  </tr>
							  </thead>   
							  <tbody id="state">
								<volist name="list" id="vo">
								<tr>
									<td>{$vo.set_id}</td>
                                    <td>{$vo.set_name}</td>
                                    <td>{$vo.set_url}</td>
									<td>
									<if condition="$vo.set_stata eq '1'">开启</if><if condition="$vo.set_stata eq '2'">关闭</if>
									</td>
									<td>
									
										<a href="#" data-id="{$vo.set_id}" data-type="state">										
											<if condition="$vo.set_stata eq '1'"><span class="label label-warning" data-state="2">关闭</span></if>
											<if condition="$vo.set_stata eq '2'"><span class="label label-success" data-state="1">开启</span></if>
										
										</a>
									
									</td>
									<td>
									
									<if condition="$vo.set_power eq '1'">
										<a class="btn btn-info" data-id="{$vo.set_id}" data-type="edit" role="button" data-toggle="modal" href="#edit">
											<i class="fa fa-edit "></i>                                            
										</a>

									 </if>
									<!--自定义-->
									<if condition="$vo.set_power eq '3'">
										<a class="btn btn-info" data-id="{$vo.set_id}" data-type="edit" role="button" data-toggle="modal" href="#edit">
											<i class="fa fa-edit "></i>                                            
										</a>
										<a class="btn btn-danger"  href="#" data-id="{$vo.set_id}" data-type="del">
											<i class="fa fa-trash-o "></i> 

										</a>
									</if>									
									
									
									</td>
								</tr>
								</volist>
							  </tbody>
						  </table>  
							<ul class="pagination">
								{$page}
							 </ul>						  
						</div>
					</div>
				</div><!--/col-->
			
			</div><!--/row-->				
			
		<!-- end: Content -->
		<br><br><br>
		
	</div><!--/container-->
<!--添加导航程序-->	
        <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="again" class="modal fade add_right">
		
            <div class="modal-dialog public-top"  id="">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="title">新增导航程序</h4>
                    </div>
					<form action="" method="post" class="form-horizontal" >
						<div class="modal-body">
							<label class="">名称:</label>
							<div class="">
								<input type="text" id="set_name" name="set_name" value="" class="form-control placeholder-no-fix" >
							</div></br>
							<label class="">URL:</label>
							<div class="">
								<input type="text" id="set_url" name="set_url" class="form-control placeholder-no-fix">
							</div></br>

							<label class="">上级:</label>
							<div class="">								
				                <select id="set_pid" name="set_pid" class="form-control" size="1">
				                    <option value="0">顶级导航</option>
									<volist name="admmenu" id="vo">
										<if condition="$vo.set_pid eq '0'">
											<option value="{$vo.set_id}">{$vo.set_id}{$vo.set_name}</option>
										</if>
									</volist>
				                 </select>
				            </div>
						</div></br>
						<input type="hidden"  name="set_stata" id="set_stata" value="1">
						<input type="hidden"  name="id" id="set_id" value="">
						<input type="hidden"  name="set_power" id="set_power" value="3">
						<input type="hidden"  name="type" id="type" value="set_add">
						<div class="modal-footer">
							<button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
							<button class="btn btn-primary mypost" type="sunmit">确认</button>
						</div>
					</form>	
              </div>
            </div>
        </div>		
</block>
<block name="script">
<script>
$("#add_right").click(function(){
	$(".add_right").attr('id','again');
	$("#title").html('新增导航程序');
	$("#set_name").val('');
	$("#set_url").val('');
	$("#set_stata").val(1);
	$("#set_power").val(3);
	$("#type").val('set_add');
	var html = '<option value="0">顶级导航</option>';
	    html += '<volist name="admmenu" id="vo"><if condition="$vo.set_pid eq '0'"><option value="{$vo.set_id}">{$vo.set_name}</option></if></volist>';
	$("#set_pid").html(html);
});

$("#state tr td a").click(function(){

    var id = $(this).attr('data-id');
	var state = $(this).find('span').attr('data-state');
	var type = $(this).attr('data-type');
	

	if (type=='edit'){			
		$(".add_right").attr('id',type);
		$("#title").html('修改导航程序');
	}
	
	
	if (id) {
		$.ajax({
			url:"{:U('Admset/adminset')}",
			data:{id:id,type:type,state:state},
			type:'post',
			dataType:'json',
			success:function (e) {

			if (e.data) {
				$("#set_name").val(e.data.set_name);
				$("#set_url").val(e.data.set_url);
				$("#set_stata").val(e.data.set_stata);
				$("#set_power").val(e.data.set_power);
				$("#set_id").val(e.data.set_id);
				$("#type").val('set_edit');
				var html = '<option value="'+e.data.set_pid+'">'+e.parent+'</option>';
				$("#set_pid").html(html);
				
			}			
			//alert(e.info);
	
			if (e.info==1) {
				alert('开启成功');
				location.reload();
			} else if(e.info==2){
				alert('关闭成功');
				location.reload();
			} else if(e.info==3){
				alert('修改失败');
			} else if(e.info==4){
				alert('您没有权限');
			} else if(e.info==5){
				alert('删除成功');
				location.reload();
			} else if(e.info==6){
				alert('删除失败');
			}
			
			}
		});	
	} 

});
</script>
</block>	









